/*
***************************************************************************************************** 
* HessianCharp - The .Net implementation of the Hessian Binary Web Service Protocol (www.caucho.com) 
* Copyright (C) 2004-2005  by D. Minich, V. Byelyenkiy, A. Voltmann
* http://www.hessiancsharp.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
* 
* You can find the GNU Lesser General Public here
* http://www.gnu.org/licenses/lgpl.html
* or in the license.txt file in your source directory.
******************************************************************************************************  
* You can find all contact information on http://www.hessiancsharp.org
******************************************************************************************************
*
*
******************************************************************************************************
* Last change: 2005-12-25
* 2005-12-25 initial class definition by Dimitri Minich.
* ....
******************************************************************************************************
*/

#region NAMESPACES
using System;
using burlapcsharp.io;
#endregion


namespace burlapcsharp.client
{
    /// <summary>
    /// Factory for Proxy - creation.
    /// </summary>
    public class CBurlapProxyFactory
    {
        #region CLASS_FIELDS
		/// <summary>
		/// flag, that allows or not the overloaded methods (using mangling)
		/// </summary>
		private bool m_blnIsOverloadEnabled = false;

        private string m_password;
        private string m_username;

        #endregion

        #region Contructors
        public CBurlapProxyFactory()
        {
            m_username = null;
            m_password = null;
        }
        public CBurlapProxyFactory(string username, string password)
        {
            m_username = username;
            m_password = password;

        }
		#endregion

        #region PROPERTIES
        /// <summary>
        /// Returns of Sets flag, that allows or not the overloaded methods (using mangling)
        /// </summary>
        public bool IsOverloadEnabled
        {
            get { return m_blnIsOverloadEnabled; }
            set { m_blnIsOverloadEnabled = value; }
        }
        #endregion

        #region PUBLIC_METHODS

        /// <summary>
        /// Creates a new proxy with the specified URL.  The returned object
        /// is a proxy with the interface specified by api.
        /// <code>
        /// string url = "http://localhost:8080/ejb/hello");
        /// HelloHome hello = (HelloHome) factory.create(HelloHome.class, url);
        /// </code>
        /// </summary>
        /// <param name="type">the interface the proxy class needs to implement</param>
        /// <param name="strUrl">the URL where the client object is located</param>
        /// <returns>a proxy to the object with the specified interface</returns>
        public Object Create(Type type, string strUrl)
        {
            return CreateBurlapStandardProxy(strUrl, type);
        }

        /// <summary>
        /// Creates proxy object using .NET - Remote proxy framework
        /// </summary>
        /// <param name="type">the interface the proxy class needs to implement</param>
        /// <param name="strUrl">the URL where the client object is located</param>
        /// <returns>a proxy to the object with the specified interface</returns>
        private object CreateBurlapStandardProxy(string strUrl, Type type)
        {
            return new CBurlapProxyStandardImpl(type, this, new Uri(strUrl)).GetTransparentProxy();
            /*
            if ((m_username == null) && (m_password == null))
            {
                return new CBurlapProxyStandardImpl(type, this, new Uri(strUrl)).GetTransparentProxy();
            }
            else
            {
                return new CBurlapProxyStandardImpl(type, this, new Uri(strUrl), m_username, m_password).GetTransparentProxy();
            }
             */
        }
        #endregion
    }
}
